-- die_reduce_double_resist
-- created by dengc
-- 小怪死亡降低boss双抗（恶徒首领欺善怕恶专用）

return {
    apply = function(prop, baseValue)
        return baseValue;
    end,

    -- 每死一个小怪触发
    trigger = function(who, prop, args)
        local deno = tonumber(prop[3]);
        assert(deno > 0);

        local skillId = args;
        local count = who.killed_count or 0;

        local props;
        local value;

        -- 记录一下快要减到0时的边界情况
        local showEffect = true;

        -- 魔抗减少
        local magicResist = PropM.combine(who, "resist", "magic");

        showEffect = magicResist[3] >= 190 and true or false;

        value = prop[3];
        value = magicResist[3] >= value and value or magicResist[3];
        if magicResist[3] > 0 then
            props = { magicResist[1], magicResist[2], -value, magicResist[4], };
            PropM.record(who, props, "mixed");
        end

        -- 物抗减少
        local physicResist = PropM.combine(who, "resist", "attack");

        showEffect = showEffect or (physicResist[3] >= 190 and true or false);

        value = prop[3];
        value = physicResist[3] >= value and value or physicResist[3];
        if physicResist[3] > 0 then
            props = { physicResist[1], physicResist[2], -value, physicResist[4], };
            PropM.record(who, props, "mixed");
        end

        -- 抛出受创事件
        magicResist = PropM.combine(who, "resist", "magic");
        physicResist = PropM.combine(who, "resist", "attack");
        if showEffect then
            EventMgr.fire(event.BOSS_RECIEVE_DEBUF, { ["skillId"] = skillId, ["pos"] = DungeonBossM.getBossPos(), });
        end

    end,

    record = function(target, prop, path)
        return false;
    end
};
